package com.qf.controller.servlet;

import com.alibaba.fastjson.JSON;
import com.qf.domain.GoodsType;
import com.qf.service.GoodsTypeService;

import com.qf.service.impl.GoodsTypeServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * projectName:shopping
 * author:ydw
 * time:2022/4/19 15:48
 * description:
 */
@WebServlet("/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet {
    GoodsTypeService goodsTypeService=new GoodsTypeServiceImpl();
    public void goodstypelist(HttpServletRequest request,HttpServletResponse response){
        //查询一级分类列表
        List<GoodsType> goodsTypes=goodsTypeService.findTypeListBylevel(1);
        //将数据返回给前端
        Object json = JSON.toJSON(goodsTypes);
        try {
            response.getWriter().print(json);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
